@echo off
setlocal enabledelayedexpansion
:: 让命令本身也打印出来，方便调试
echo === 1. archive old version ===
ssh 84 "bash -c 'cd /application/authority/gateway/ && ./archive.sh'"
if errorlevel 1 goto :fail

echo === 2. upload jar ===
scp .\jv_gateway\target\*.jar 84:/application/authority/gateway/
if errorlevel 1 goto :fail

echo === 3. upload lib ===
ssh 84 "mkdir -p /application/authority/gateway/lib"
scp -r .\jv_gateway\target\lib\* 84:/application/authority/gateway/lib/
if errorlevel 1 goto :fail

echo === 4. restart ===
ssh 84 "bash /application/authority/gateway/restart.sh"
if errorlevel 1 goto :fail

echo === all done ===
pause
exit /b 0

:fail
echo !!! step failed, exit code: %errorlevel% !!!
pause
exit /b 1